import request from '@/utils/request'
// 主页
export function getHome () {
  return request({
    url: '/home/index'
  }).then(res => {
    return res.data
  })
}
// 分类
export function getItems () {
  return request({
    url: '/catalog/index'
  }).then(res => {
    return res.data
  })
}
//  分类-侧边框
export function getItemsId (item) {
  return request({
    url: '/catalog/current?id=' + item
  }).then(res => {
    return res.data
  })
}
// 分类点击后跳转
export function getItemslist (item) {
  return request({
    url: '/goods/list?categoryId=' + item
  }).then(res => {
    return res.data
  })
}
// 注册
export function addUser (sms, phone, password, password2, username) {
  return request({
    url: '/auth/register',
    method: 'POST',
    contentType: 'application/json;charset=UTF-8',
    data: {
      code: sms,
      mobile: phone,
      password: password,
      repeatPassword: password2,
      username: username
    }
  })
}
// 登录
export function getLogin (username, password) {
  return request({
    url: '/auth/login',
    method: 'post',
    ContentType: 'application/json;charset=UTF-8',
    data: {
      username: username,
      password: password
    }
  })
}
// 设置
export function alterusername (username, Authorization) {
  return request({
    url: '/auth/info',
    method: 'get',
    ContentType: 'application/json;charset=UTF-8',
    data: {
      username: username,
      token: Authorization
    }
  })
}

// export function getinformation (token) {
//   return request({
//     url: '/auth/info',
//     method: 'get',
//     ContentType: 'application/json;charset=UTF-8',
//     data: {
//       token: token
//     }
//   })
// }
// 分类 - 点击跳转 - 详情
export function getdataList (page, limit, id) {
  return request({
    url: '/goods/list?categoryId=' + id + '&page=' + page + '&limit=' + limit,
    method: 'get'
  }).then(res => {
    return res.data
  })
}
// 单独产品 http://42.192.236.134:8090/wx/goods/detail?id=1055012
